<template>
  <div class="page-list-live">
    <PageList>
      <template #header>
        <div style="width: 100%; overflow: hidden;">
          <div style="float: left;">调度管理</div>
          <!-- <el-button style="float: right;" type="primary" @click="handleAdd">新建基站</el-button> -->
        </div>
      </template>
      <!-- <template #filter>
        <ListFilter
          :form="topFilter"
          @search="handleSearch"
          @reset="handleReset"
        ></ListFilter>
      </template>
      <template #table>
        <ListTable
          ref="RefListTable"
          :loading="tableLoading"
          :table-data="tableData"
          :table-col="tableCol"
        >
          <template slot="col1" slot-scope="scope">
            <el-button
              :loading="scope.row.loadingEdit"
              size="mini"
              type="text"
              @click="handleRowEdit(scope.row)"
            >
              编辑
            </el-button>
            <el-button
              :loading="scope.row.loadingDel"
              size="mini"
              type="text"
              @click="handleRowDel(scope.row)"
            >
              删除
            </el-button>
          </template>
        </ListTable>
      </template>-->
    </PageList>
    <Dispatching ref="RefAccountsEdit" @success="afterEditSuccess"></Dispatching>
  </div>
</template>

<script>
  import listMixin from '@/mixins/list'
  import Dispatching from './components/Dispatching.vue'
  // import ListFilter from '@/components/ListFilter'
  import { user } from '@/api/api'
  export default {
    components: {
      Dispatching,
      // ListFilter
    },
    mixins: [listMixin],
    data() {
      return {
        topFilter: {
          name: { label: '调度编码', placeholder: '调度编码' },
          nae: { label: '调度名称', placeholder: '调度名称' },
          nme: { label: '状态', placeholder: '请输入状态' },
        },
        tableData: [],
        tableCol: [
          { prop: 'loginName', label: '调度编码' },
          { prop: 'name', label: '调度名称' },
          { prop: 'loginName', label: '时间间隔' },
          { prop: 'name', label: '间隔模式' },
          { prop: 'loginName', label: '最后运行时间' },
          { prop: 'name', label: '状态' },
          { label: '操作', custom: 'col1' }
        ]
      }
    },
    methods: {
      // 请求列表数据
      async getList(query) {
        // this.tableLoading = true
        // try {
        //   let obj = query || { pageIndex: 1, pageSize: 10 }
        //   const res = await user('get', obj, false)
        //   const { data: { items: resData, count, pageIndex } } = res
        //   this.tableData = resData.map(item => {
        //     item.loadingEdit = false
        //     item.loadingDel = false
        //     return item
        //   })
        //   this.$nextTick(() => {
        //     this.$refs['RefListTable'].update({ page: pageIndex, count })
        //     this.tableLoading = false
        //   })
        // } catch (err) {
        //   this.tableLoading = false
        //   console.error('getList err: ', err)
        // }
      },
      afterEditSuccess() {
        this.getList()
      },
      handleAdd() {
        this.$refs['RefAccountsEdit'].open()
      },
      handleRowEdit(row) {
        this.$refs['RefAccountsEdit'].open(row)
      },
      passwordHandleEdit(row) {
        this.$refs['RefPassword'].open(row)
      },
      async delRowReq(row) {
        try {
          let obj = { id: row.id, value: null }
          await user('delete', obj, true)
          row.loadingDel = false
          await this.getList()
          this.$message({
            type: 'success',
            message: '删除成功'
          })
        } catch (err) {
          row.loadingDel = false
          console.error('handleRowDel err: ', err)
        }
      },
      handleRowDel(row) {
        row.loadingDel = true
        this.$_delConfirm(
          '管理员',
          () => {
            this.delRowReq(row)
          },
          () => {
            row.loadingDel = false
          }
        )
      }
    }
  }
</script>

<style lang="scss" scoped>
</style>
